import App from 'next/app'
import React from 'react'
import { Provider } from 'react-redux'
import makeStore from '../store'
import Layout from '../components/Layout'
import '../styles/globals.css'

const store = makeStore()

class MyApp extends App {
  static async getInitialProps({ Component, ctx }) {
    let pageProps = {}
    if (Component.getInitialProps) {
      pageProps = await Component.getInitialProps(ctx)
    }
    return { pageProps }
  }

  componentDidMount() {}

  render() {
    const { Component, pageProps } = this.props

    return (
      <Provider store={store}>
        <Layout
          title={pageProps.title}
        >
          <Component {...pageProps} />
        </Layout>
      </Provider>
    )
  }
}

export default MyApp